<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">/*
 * Copyright (c) 2016 JUI All rights reserved.
 */
;(function () {


    var hoverInited = false;

<span id=''>    /**
</span>     * 所有视图类的父类
     * @ignore
     * @class
     */
    JUI.Class('View', {
<span id='global-method-init'>        /**
</span>         * 构造函数
         * @ignore
         */
        init: function (cmp) {
            this.cmp = cmp;

            this.createOuter();
        }
        // 构建指令名称
        , buildDirectiveName: function (name) {
            return name + this.cmp.id;
        }
        , createOuter: function () {
            this.$wraper = $('&lt;div&gt;&lt;/div&gt;')
                .css({position: this.opt('position')});

            if (this.opt('zindex')) {
                this.setZIndex(this.opt('zindex'));
            }

            if (this.opt('autoHide')) {
                this.$wraper.hide();
            }
        }
        , setZIndex: function (index) {
            this.$wraper.css({'z-index': index});
        }
        , getZIndex: function () {
            return this.$wraper.css('z-index');
        }
        , getTemplate: function () {
            alert('类' + this.getClassName() + '必须重写View.getTemplate()');
        }
        // 渲染
        , render: function (dom) {
            var $wraper = this.getWraper();
            var renderDom = dom || this.getRenderDom();

            this.$tpl = this.getTemplate();

            $wraper.html(this.$tpl);

            $(renderDom).append($wraper);

            this.afterRender();
        }
        , getRenderDom: function () {
            var renderId = this.opt('renderId');
            return renderId &amp;&amp; typeof renderId === 'string'
                ? document.getElementById(renderId)
                : document.body;
        }
        // 渲染后的动作
        , afterRender: function () {
            this.cmp.fire('RenderSuccess', {dom: this.$wraper, cmp: this.cmp});
        }
        , getWraper: function () {
            return this.$wraper;
        }
        , opt: function (optName, val) {
            return this.cmp.opt(optName, val);
        }
        , refresh: function () {

        }
        , show: function () {
            this.getWraper().show();
        }
        , hide: function () {
            this.getWraper().hide();
        }
    });

})();</pre>
</body>
</html>
